<?php


namespace app\sys\model;


use think\Model;

class Conn extends Model
{
    protected $autoWriteTimestamp = true;

    public static function addCount($no,$deviceType,$clientId,$type)
    {
        $c = Conn::where("device_type",$deviceType)->where("no",$no)->find();
        if($c){
            $resC = Conn::where("id",$c["id"])->data(["conn_count"=>$c["conn_count"]+1])->update();
            if(!$resC)return "修改失败";
        }else{
            $ar = ["no"=>$no,"device_type"=>$deviceType];
            $resC = Conn::create($ar);
            if(!$resC)return "修改失败";
        }
        ConnLog::add($no,$clientId,$type);
        return "";
    }
}